/**
 * Created by joustany on 17/11/14.
 */
//第一个拍照页面
function patOne() {
    get_wx_config()
    if(getCookie("patOne")){
        alert('你的内存不足')
    }else{
        document.cookie="patOne=第二个拍照页";
    }
}
//第二个拍照页面
function patTow() {
    if(getCookie("patTow")){
        alert('你的内存不足')
    }else{
        document.cookie="patTow=第二个拍照页";
    }
    get_wx_config()
}
//微信签名
function get_wx_config() {
    var url = window.location.href
    $.ajax({
        type: "POST",
        url: api('/h5/get-jsapi-sign-package'),
        data: {
            url:url,
        },
        dataType: "json",
        success: function (res) {
            console.log(res)
            var signPackage = res.data.signPackage
            wx.config({
                debug: false,
                appId: signPackage.appId,
                timestamp: signPackage.timestamp,
                nonceStr: signPackage.nonceStr,
                signature: signPackage.signature,
                jsApiList: [
                    "chooseImage", "previewImage", "uploadImage", "downloadImage"
                ]
            });
            wx.ready(function () {
                // alert("wx.config success.");
            })
        }
    });
}
//取cookie某个值是否
function getCookie(cookieName) {
    var strCookie = document.cookie;
    var arrCookie = strCookie.split("; ");
    for(var i = 0; i < arrCookie.length; i++){
        var arr = arrCookie[i].split("=");
        if(cookieName == arr[0]){
            return arr[1];
        }
    }
    return "";
}
